package com.heima.comment.controller;

import com.heima.comment.service.CommentService;
import com.heima.model.comment.dtos.CommentDTO;
import com.heima.model.comment.dtos.CommentLikeDTO;
import com.heima.model.comment.dtos.CommentSaveDTO;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Api(tags = "app端评论点赞", value = "app端评论点赞")
@RestController
@RequestMapping("/api/v1")
public class CommentController {
    @Autowired
    CommentService commentService;

    //保存评论
    @PostMapping("/save")
    @ApiOperation("保存评论")
    public ResponseResult saveComment(@RequestBody @Validated CommentSaveDTO dto){
        return commentService.saveComment(dto);
    }

    @ApiOperation(value = "评论点赞")
    @PostMapping("/comment/like")
    public ResponseResult findByUserIdOrEquipmentId(@RequestBody @Validated CommentLikeDTO dto) {
        return commentService.like(dto);
    }
    @ApiOperation(value = "加载评论")
    @PostMapping("/comment/load")
    public ResponseResult findByArticleId(@RequestBody @Validated CommentDTO dto) {
        return commentService.findByArticleId(dto);
    }
}

